﻿<%@ Page Title="" Language="C#" MasterPageFile="~/administrator/backend.Master" AutoEventWireup="true" CodeBehind="classroom-add.aspx.cs" Inherits="VQWEB.administrator.english.classroom.classroom_add" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Content_backend" runat="server">
    <form id="frmObjects" action="" method="post">
    </form>
 </asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="Script_backend" runat="server">
    <script type="text/javascript">
        ShowToolBar("edit");
        var url_ashx = "/admin/english/classroom/handler";
        var url_input = '<%=ResolveUrl("~/administrator/templates/input.tpl") %>';

        $(document).ready(function () {
            if (CheckAtionInPath("add")) {
                loadform(0, "", "", false);
            }
            else if (CheckAtionInPath("edit")) {
                $.get(url_ashx, { view_classroom: "view_classroom", Id: GetId() }, function (data) {
                    var obj = $.parseJSON(data);
                    loadform(obj.id, obj.title,obj.content, obj.active);
                });
            }

        });

        function loadform(id, title,content, active) {
            $.jqoteload(url_input, function (tmpl) {

                $("#frmObjects").single("hidden", "classroom_id", id, null, null, tmpl.input_tpl);
                $("#frmObjects").single("text", "classroom_title", title, "Title:", null, tmpl.input_tpl);
                $("#frmObjects").single("textarea", "classroom_content", content, "Content:", null, tmpl.input_tpl);
                $("#frmObjects").single("checkbox", "classroom_active", true, "Active", active, tmpl.input_tpl);
            });

        }
                
        $(document).on("click", "#btnCancel", function () {
            window.location = "/admin/english/classroom/list";
        });
        $(document).on("click", "#btnSave", function () {
            var arr = $("#frmObjects").serializeObject();
            $.post(url_ashx, { add_classroom: window.escape(arr) }, function (data) {
                alert(data);
                window.location = "/admin/english/classroom/list";
            });
        });
    </script>
</asp:Content>
